//
//  BTree.h
//  SimulacraDB
//
//  Created by Andre Cohen on 8/11/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "BTreeNode.h"
#import "IndexProtocol.h"
#import "IndexRecord.h"

@interface BTree : NSObject <IndexProtocol>{
	BTreeNode *root;
}

- (IndexRecord *)findObject:(IndexRecord *)object;
- (NSArray *)findLeafFor:(IndexRecord *)object;

- (void)insertObject:(IndexRecord *)object;
- (void)removeObject:(IndexRecord *)object;

- (void)removeKey:(IndexRecord *)object from:(BTreeNode *)node;
- (void)replaceKey:(IndexRecord *)oldKey with:(IndexRecord *)newKey inNode:(BTreeNode *)node;

- (BTreeNode *)siblingOf:(BTreeNode *)node parent:(BTreeNode *)parent direction:(int)d;
- (BTreeNode *)insertInOrder:(IndexRecord *)object edge:(BTreeNode *)edge into:(BTreeNode *)node;
- (IndexRecord *)smallestOf:(BTreeNode *)node;

- (void)inOrder:(BTreeNode *)current;

@end
